<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>数据绑定</title>
    <script type="text/javascript" src="../js/jquery-3.4.1.min.js"></script>
    <script>
        $(function(){
            $("#add").click(function(){
                // 向元素中绑定数据
                $("#add").data("id","1");
                $("#add").data("name","admin");
                $("#find").data("id","10");
                $("#find").data("username","admin");
                $("#find").data("password","123456");
            });
            $("#find").click(function(){
                console.log($("#add").data("id"))
                console.log($("#add").data("name"))
                console.log($("#find").data("id"))
                console.log($("#find").data("username"))
                console.log($("#find").data("password"))
                console.log($("#add").data("password"))
            });
            $("#del").click(function(){
                $("#find").removeData("id")
                $("#find").removeData("password")
            });
        })
    </script>
</head>
<body>
<button id="add">绑定数据</button>
<button id="find">获取数据</button>
<button id="del">移除数据</button>
</body>
</html>